<?php

namespace common\model;

use think\model\RelationModel;
use think\module\Module;
use teamones\dbeventObserver\SplSubjectEnforcer;
use teamones\dbeventObserver\interfaces\SplSubject;

class DelayOrderTaskModel extends RelationModel
{
    const TYPE_REQUEST_DELAY = 'request_delay'; // 申请延期
    const TYPE_WORK_ORDER = 'work_order'; // 工单延期
    const TYPE_DOWNSTREAM_DELAY = 'downstream_delay'; // 申请延期导致的下游延期
    const TYPE_TODAY_DONE = 'today_done'; // 今日完成
    const TYPE_DEMAND_ORDER = 'demand_order'; // 今日完成

    const ABNORMAL_INFO_NOT_DONE = 'not_done'; //今日未完成
    const ABNORMAL_INFO_NOT_DELIVERY = 'not_delivery'; //今日未交付


    // 确认状态
    const CONFIRM_STATUS_STEP_CATEGORY_CONFIRMING = 'step_category_confirming'; // 环节确认中
    const CONFIRM_STATUS_PRODUCER_CONFIRMING = 'producer_confirming'; // 制片确认中
    const CONFIRM_STATUS_YES = 'yes'; // 通过
    const CONFIRM_STATUS_NO = 'no'; // 拒绝

    //自动验证
    protected $_validate = [
        ['number', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['name', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['episode_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['step_category_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
    ];

    //自动完成
    protected $_auto = [
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
        ['uuid', 'create_uuid', self::MODEL_INSERT, 'function'],
    ];

    public function getJsonAttr($value)
    {
        return json_decode($value,true);
    }
}
